import request from './request.js'

//获取用户待办
export function getUserTodoList(params) {
  return request({
    url: `wflow/process/task/todoList`,
    method: 'get',
    params: params,
  })
}

//获取用户发起的实例
export function getUserSubmittedList(params) {
  return request({
    url: `wflow/process/mySubmitted`,
    method: 'get',
    params: params,
  })
}

//获取所有发起的实例
export function getSubmittedList(params) {
  return request({
    url: `wflow/process/submittedList`,
    method: 'get',
    params: params,
  })
}

//获取我已处理的所有审批实例
export function getIdoList(params) {
  return request({
    url: `wflow/process/task/idoList`,
    method: 'get',
    params: params,
  })
}

//查询流程进度及表单
export function getFormAndProcessProgress(instanceId, nodeId) {
  return request({
    url: `wflow/process/progress/${instanceId}/${nodeId}`,
    method: 'get',
  })
}

//处理任务
export function approvalTask(params) {
  return request({
    url: `wflow/process/task/handler`,
    method: 'post',
    data: params,
  })
}


//处理任务2
export function approvalTask2(params,owner){
  return request({
    url: `wflow/process/task/replace/${owner}/handler`,
    method: 'post',
    data: params
  })
}

//获取流程实例表单数据
export function getInstanceFormData(instanceId) {
  return request({
    url: `wflow/process/form/data/by/${instanceId}`,
    method: 'get',
  })
}

//获取可回退的节点
export function getEnableRecallNodes(instanceId, taskId) {
  return request({
    url: `wflow/process/task/recall/nodes`,
    method: 'get',
    params: { instanceId: instanceId, taskId: taskId },
  })
}

export function getTaskNodeSettings(taskId){
  return request({
    url: `wflow/process/task/settings/${taskId}`,
    method: 'get'
  })
}
// 删除流程实例
export function getTaskDeletes(taskId){
  return request({
    url: `wflow/process/instance/${taskId}`,
    method: 'delete'
  })
}

//流程完结修改表格内容
export function updateInstanceFormData(params){
  return request({
    url: `wflow/newProcess/updateInstanceFormData`,
    method: 'post',
    data: params
  })
}

//流程干预 流程管理画面
export function updateHistoryProcessStatus(params){
  return request({
    url: `wflow/newProcess/updateHistoryProcessStatus/${params}`,
    method: 'post',
    data: params
  })
}

//作废流程 流程管理画面
export function deleteProcessInstance(params){
  return request({
    url: `wflow/newProcess/deleteProcessInstance/${params}`,
    method: 'post',
    data: params
  })
}

//抄送流程
export function processCopy(params){
  return request({
    url: 'wflow/newProcess/processCopy',
    method: 'post',
    data: params
  })
}

export default {
  getUserTodoList,
  getUserSubmittedList,
  getSubmittedList,
  getFormAndProcessProgress,
  approvalTask,
  approvalTask2,
  getInstanceFormData,
  getEnableRecallNodes,
  getIdoList,
  getTaskNodeSettings,
  getTaskDeletes,
  updateInstanceFormData,
  updateHistoryProcessStatus,
  deleteProcessInstance,
  processCopy
}
